home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / unixcpio.gz / unixnet.cpio / netrom.h < prev    next >
C/C++ Source or Header  |  1994-07-11  |  6KB  |  184 lines

  1. /* net/rom support definitions
  2.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  3.  * non-commercial distribution only.
  4.  */
  5.  
  6. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  7. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  8. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  9. #define NR3NODEHL    7    /* nodes bc header length */
  10.  
  11. #define NRNUMIFACE    10    /* number of interfaces associated */
  12.                 /* with net/rom network layer      */
  13. #define NRNUMCHAINS    17    /* number of chains in the */
  14.                 /* neighbor and route hash tables */
  15. #define NRRTDESTLEN    21    /* length of destination entry in */
  16.                 /* nodes broadcast */
  17. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  18.                 /* nodes packet */
  19.  
  20. /* Internal representation of net/rom network layer header */
  21. struct nr3hdr {
  22.     struct ax25_addr source ;    /* callsign of origin node */
  23.     struct ax25_addr dest ;        /* callsign of destination node */
  24.     unsigned ttl ;            /* time-to-live */
  25. } ;
  26.  
  27. /* Internal representation of net/rom routing broadcast destination */
  28. /* entry */
  29. struct nr3dest {
  30.     struct ax25_addr dest ;        /* destination callsign */
  31.     char alias[7] ;            /* ident, upper case ASCII, blank-filled */
  32.     struct ax25_addr neighbor ;    /* best-quality neighbor */
  33.     unsigned quality ;        /* quality of route for this neighbor */
  34. } ;
  35.  
  36.  
  37. /* net/rom interface table entry */
  38. struct nriface {
  39.     struct interface *interface ;    /* pointer to ax.25 interface */
  40.     char alias[7] ;            /* alias for this interface's node */
  41.                     /* broadcasts */
  42.     unsigned quality ;        /* net/rom link quality estimate */
  43. } ;
  44.  
  45. /* net/rom neighbor table structure */
  46. struct nrnbr_tab {
  47.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  48.     struct nrnbr_tab *prev ;
  49.     char call[AXALEN*3] ;        /* call of neighbor + 2 digis max */
  50.     unsigned interface ;        /* offset of neighbor's port in */
  51.                     /* interface table */
  52.     unsigned refcnt ;        /* how many routes for this neighbor? */
  53. } ;
  54.  
  55. #define    NULLNTAB    (struct nrnbr_tab *)0
  56.  
  57.  
  58. /* A list of these structures is provided for each route table */
  59. /* entry.  They bind a destination to a neighbor node.  If the */
  60. /* list of bindings becomes empty, the route table entry is    */
  61. /* automatically deleted.                                       */
  62.  
  63. struct nr_bind {
  64.     struct nr_bind *next ;        /* doubly linked list */
  65.     struct nr_bind *prev ;
  66.     unsigned quality ;        /* quality estimate */
  67.     unsigned obsocnt ;        /* obsolescence count */
  68.     unsigned flags ;
  69. #define    NRB_PERMANENT    0x01        /* entry never times out */
  70. #define NRB_RECORDED    0x02        /* a "record route" entry */
  71.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  72. } ;
  73.  
  74. #define    NULLNRBIND    (struct nr_bind *)0
  75.  
  76.  
  77. /* net/rom routing table entry */
  78.  
  79. struct nrroute_tab {
  80.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  81.     struct nrroute_tab *prev ;
  82.     char alias[7] ;            /* alias of node */
  83.     struct ax25_addr call ;        /* callsign of node */
  84.     unsigned num_routes ;        /* how many routes in bindings list? */
  85.     struct nr_bind *routes ;    /* list of neighbors */
  86.  
  87. } ;
  88.  
  89. #define    NULLNRRTAB    (struct nrroute_tab *)0
  90.  
  91.  
  92. /* The net/rom nodes broadcast filter structure */
  93. struct nrnf_tab {
  94.     struct nrnf_tab *next ;        /* doubly linked list */
  95.     struct nrnf_tab *prev ;
  96.     struct ax25_addr neighbor ;    /* call of neighbor to filter */
  97.     unsigned interface ;        /* filter on this interface */
  98. } ;
  99.  
  100. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  101.  
  102.  
  103. /* The interface table */
  104. extern struct nriface nrifaces[NRNUMIFACE] ;
  105.  
  106. /* How many interfaces are in use */
  107. extern unsigned nr_numiface ;
  108.  
  109. /* The neighbor hash table (hashed on neighbor callsign) */
  110. extern struct nrnbr_tab *nrnbr_tab[NRNUMCHAINS] ;
  111.  
  112. /* The routes hash table (hashed on destination callsign) */
  113. extern struct nrroute_tab *nrroute_tab[NRNUMCHAINS] ;
  114.  
  115. /* The nodes broadcast filter table */
  116. extern struct nrnf_tab *nrnf_tab[NRNUMCHAINS] ;
  117.  
  118. /* filter modes: */
  119. #define    NRNF_NOFILTER    0    /* don't filter */
  120. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  121. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  122.  
  123. /* The filter mode */
  124. extern unsigned nr_nfmode ;
  125.  
  126. /* The time-to-live for net/rom network layer packets */
  127. extern unsigned nr_ttl ;
  128.  
  129. /* The obsolescence count initializer */
  130. extern unsigned obso_init ;
  131.  
  132. /* The threshhold at which routes becoming obsolete are not broadcast */
  133. extern unsigned obso_minbc ;
  134.  
  135. /* The quality threshhold below which routes in a broadcast will */
  136. /* be ignored */
  137. extern unsigned nr_autofloor ;
  138.  
  139. /* The maximum number of routes maintained for a destination. */
  140. /* If the list fills up, only the highest quality routes are  */
  141. /* kept.  This limiting is done to avoid possible over-use of */
  142. /* memory for routing tables in closely spaced net/rom networks. */
  143. extern unsigned nr_maxroutes ;
  144.  
  145. /* Whether we want to broadcast the contents of our routing
  146.  * table, or just our own callsign and alias:
  147.  */
  148. extern unsigned nr_verbose ;
  149.  
  150. /* The netrom pseudo-interface */
  151. extern struct interface *nr_interface ;
  152.  
  153. /* Functions */
  154. #if    (UNIX || ATARI_ST)
  155. extern struct nrroute_tab *find_nrroute() ;
  156. extern struct ax25_addr *find_nralias() ;
  157. extern struct nrnbr_tab *find_nrnbr() ;
  158. extern struct nrnf_tab *find_nrnf() ;
  159. extern int nr_routeadd() ;
  160. extern int nr_routedrop() ;
  161. extern int nr_nfadd() ;
  162. extern int nr_nfdrop() ;
  163. extern char *nr_getroute() ;
  164. extern int ntohnr3() ;
  165. extern struct mbuf *htonnr3() ;
  166. extern int ntohnrdest() ;
  167. extern struct mbuf *htonnrdest() ;
  168. #else
  169. extern struct nrroute_tab *find_nrroute(struct ax25_addr *) ;
  170. extern struct ax25_addr *find_nralias(char *) ;
  171. extern struct nrnbr_tab *find_nrnbr(struct ax25_addr *, unsigned) ;
  172. extern struct nrnf_tab *find_nrnf(struct ax25_addr *, unsigned) ;
  173. extern int nr_routeadd(char *, struct ax25_addr *, unsigned,
  174.                        unsigned, char *, unsigned, unsigned) ;
  175. extern int nr_routedrop(struct ax25_addr *, struct ax25_addr *, unsigned) ;
  176. extern int nr_nfadd(struct ax25_addr *, unsigned) ;
  177. extern int nr_nfdrop(struct ax25_addr *, unsigned) ;
  178. extern char *nr_getroute(struct ax25_addr *) ;
  179. extern int ntohnr3(struct nr3hdr *,struct mbuf **) ;
  180. extern struct mbuf *htonnr3(struct nr3hdr *) ;
  181. extern int ntohnrdest(struct nr3dest *,struct mbuf **) ;
  182. extern struct mbuf *htonnrdest(struct nr3dest *) ;
  183. #endif
  184.